/**
 * Created by qunxing.du on 2016/7/18.
 * Copyright 2016 汉威.智慧环保事业部 Limited.
 * All rights reserved.
 */
package com.hw.one.collect.gdyc.job;

import com.hw.one.collect.gdyc.data.GdRawFiveMinDataService;
import com.hw.one.collect.gdyc.memento.GdycCareTaker;
import com.hw.one.collect.gdyc.memento.GdycOriginator;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 广德扬尘原始5min数据job
 */
@Component
public class GdRawFiveMinJob extends GdJob {

    @Resource
    private GdRawFiveMinDataService gdRawFiveMinDataService;

    @Override
    public void start() {
        Calendar c = Calendar.getInstance();
        Date curDate = c.getTime();
        c.add(Calendar.MINUTE,-GD_RAW_FIVEMIN_INTERVAL);
        Date prevDate = c.getTime();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:00");
        String endDate = sdf.format(curDate);
        String startDate = sdf.format(prevDate);
        Map<String,Object> map = new HashMap<>();
        map.put("startTime",startDate);
        map.put("endTime",endDate);
        //拉取数据
        String data = gdRawFiveMinDataService.pull(map);
        //推送数据
        push(data,startDate,endDate);
    }
}
